using System;
using System.Windows.Forms;
using System.Drawing;

namespace DrawTools
{
	/// <summary>
	/// Line tool
	/// </summary>
	class ToolLine : ToolObject
	{
        public ToolLine()
        {
            Cursor = new Cursor(Common.FunctionClass.getRunPath() + @"\Resources\Line.cur");
        }

        public override void OnMouseDown(KKDraw drawArea, MouseEventArgs e)
        {
            Point point = drawArea.BackTrackMouse(new Point(e.X, e.Y));
            AddNewObject(drawArea, new DrawLine(point.X, point.Y, point.X + 1, point.Y + 1));
        }

        public override void OnMouseMove(KKDraw drawArea, MouseEventArgs e)
        {
            drawArea.Cursor = Cursor;

            if ( e.Button == MouseButtons.Left )
            {
                Point point = drawArea.BackTrackMouse(new Point(e.X, e.Y));
                drawArea.GraphicsList[0].MoveHandleTo(point, 2);
                drawArea.Refresh();
            }
        }
    }
}
